package com.ruoyi.file.utils;

import java.util.LinkedList;
import java.util.Queue;
import java.util.UUID;

/**
 * @author william.zhao
 * @date 2023/11/06
 * @version 1.0
 * @since jdk-17.0.2
 */
public class UUIDHelper {

    private static Queue<String> QUEUE32 = new LinkedList<>();
    private static Queue<String> QUEUE36 = new LinkedList<>();

    /**
     * get 32-bit UUID。
     * @return 32-bit UUID.
     */
    public static String get32UUID() {
        if (QUEUE32.size() < 300) {
            for (int i = 0; i < 3000; i++) {
                QUEUE32.add(UUID.randomUUID().toString().replace("-", ""));
            }
        }

        return QUEUE32.remove();
    }

    /**
     * get 36-bit UUID。
     * @return 36-bit UUID
     */
    public static String get36UUID() {
        if (QUEUE36.size() < 300) {
            for (int i = 0; i < 3000; i++) {
                QUEUE36.add(UUID.randomUUID().toString());
            }
        }
        return QUEUE36.remove();
    }

}
